package 力扣日常刷题.木22二月.第17天223;

import java.util.Stack;

/**
 * @author 帅小伙
 * @date 2022/2/23
 * @description
 */
public class Demo146两个栈实现队列 {


    class CQueue {
        Stack<Integer> s1;
        Stack<Integer> s2;

        public CQueue() {
            s1 = new Stack();
            s2 = new Stack();
        }

        public void appendTail(int value) {
            s1.add(value);
        }

        public int deleteHead() {
            if(s1.isEmpty() && s2.isEmpty()) return -1;
            if (s2.isEmpty()){
                while(!s1.isEmpty()){
                    s2.push(s1.pop());
                }
            }
            return s2.pop();
        }
    }

}
